﻿<cftry>

<cfset callback = url.callback />
<cfset page     = url.page />
<cfset start    = url.start />
<cfset sort     = url.sort />
<cfset dir      = url.dir />
<cfset limit    = url.limit />


<cfquery name="getExitForm" datasource="IBOSE_GLOBAL">
	SELECT  CONTROLNUMBER,
			company,
			dateofaccomplishment,
			nameofemployee,
			employeenumber,
			immediatesuperior,
			department,
			age,
			currentposition,
			positionuponhire,
			datehired,
			effectdateresign,
			lengthofservice,
			localopportunity1,
			localopportunity2,
			localopportunity3,
			localopportunity4,
			localopportunity5,
			localopportunity6,
			localopportunity7,
			localopportunity8,
			localopportunity9,
			localopportunity10,
			localopportunity11,
			localopportunity12,
			localopportunity13,
			localopportunity14,
			localopportunity15,
			localopportunity16,
			localopportunity17,
			localopportunity18,
			localopportunity19,
			industrynxtemp,
			companynxtemp,
			expectedtomeet,
			expectmeetremarks,
			changesaffected,
			changesremarks,
			developfull,
			developfullremarks,
			answerproblems,
			problemsremarks,
			improvements,
			improvementsremarks,
			factorsfacilitated,
			factorshindered,
			comppolicies,
			comppolicyremarks,
			compreputation,
			compreputationremarks,
			seniorlead,
			seniorleadremarks,
			superiorimmed,
			superiorimmedremarks,
			coworkers,
			coworkersremarks,
			customers,
			customersremarks,
			salary,
			salaryremarks,
			benefits,
			benefitsremarks,
			perfmgnt,
			perfmgntremarks,
			recognition,
			recognitionremarks,
			workk,
			workremarks,
			resourcespeople,
			resourcespeopleremarks,
			empcommu,
			empcommuremarks,
			workprocess,
			workprocessremarks,
			careeropp,
			careeroppremarks,
			traindevopp,
			traindevoppremarks,
			worklifebal,
			worklifebalremarks,
			workcondition,
			workconditionremarks,
			overallwork,
			overallworkremarks,
			applyfutureyes,
			applyfutureremarks,
			remarksfinalresignee,
			resigneeremarkdate,
			rmrksfinterviewer,
			interviewerrmrkdate,
			datelastupdate

	   FROM GINEXITINTERVIEWFORM
	   
	   <cfset where             = "()" >
	   
     <cfif isdefined('url.query')>
	   WHERE nameofemployee LIKE '%#url.query#%'
	 <cfelse>
	 	 <cfset where             = " (" >
            <cfset tmpdatafield      = "" >
            <cfset tmpfilteroperator = "0" >
			
        	<cfloop index="counter" from="0" to="100">
            
            	
            
            	<cftry>
					<cfset filterdatafield = trim(url['filter[#counter#][field]'])>
					<cfcatch>
						<cfbreak>
					</cfcatch>
				</cftry>
            
            	
            
            	<cfset filterdatafield = url['filter[#counter#][field]']>
				
            	<cfset filtervalue     = url['filter[#counter#][data][value]']>
				
				<cfset filtertype      = url['filter[#counter#][data][type]']>
				
				
                <cfif tmpdatafield EQ "" >
                
                	<cfset tmpdatafield = filterdatafield >	
                    	
				<cfelseif tmpdatafield NEQ filterdatafield >
                
				    <cfset where = "#where# ) AND ( " >
                    
				<cfelseif tmpdatafield EQ filterdatafield >
                
					<cfif tmpfilteroperator EQ 0>
                    	<cfset where = "#where# AND " >
                    <cfelse>
                    	<cfset where = "#where# OR " >
                    </cfif>
					
                </cfif>
                
                <cfif ucase(filtertype) EQ "STRING" >
					<cfset where = "#where##filterdatafield#  LIKE '%#filtervalue#%'" >
				<cfelseif  ucase(filtertype) EQ "NUMERIC" >
					<cfset filtercondition = url['filter[#counter#][data][comparison]']>
					<cfset expression = "#Ucase(Trim(filtercondition))#" >
               
	               		<cfif expression  EQ "LT">
						   	<cfset where = "#where##filterdatafield#  < #filtervalue#">
						<cfelseif expression EQ "GT"> 	   
							<cfset where = "#where##filterdatafield#  > #filtervalue#">
						<cfelseif expression EQ "EQ"> 	   	
							<cfset where = "#where##filterdatafield#  = #filtervalue#">
						<cfelse>
					
					</cfif>
				<cfelseif  ucase(filtertype) EQ "DATE" >
					<cfset filtercondition = url['filter[#counter#][data][comparison]']>
					<cfset expression = "#Ucase(Trim(filtercondition))#" >
					
						
	                    <cfset filtervalue = CreateODBCDateTime(filtervalue) />
               
	               		<cfif expression  EQ "LT">
	               			<cfset where = "#where##filterdatafield#  < #filtervalue#">
						<cfelseif expression EQ "GT"> 	   
							<cfset where = "#where##filterdatafield#  > #filtervalue#">
						<cfelseif expression EQ "EQ"> 	   	
							<cfset where = "#where##filterdatafield#  = #filtervalue#">
						<cfelse>
							<cfset where = "#where##filterdatafield#  = #filtervalue#">
					    </cfif>
				<cfelse>
					<!---boolean--->
					<cfif filtervalue EQ 'true' >
						<cfset filtervalue = 'Yes' >
					<cfelse>
						<cfset filtervalue = 'No' >
					</cfif>
					<cfset where = "#where##filterdatafield#  LIKE '%#filtervalue#%'" >
				</cfif>
                
                <cfset tmpdatafield      = filterdatafield >
		
            </cfloop>
            
            <cfset where = "#where#)" >
			<cfset where = Replace(where, "''", "'" , "all") />
			
			<cfif trim(where) NEQ "()">
				WHERE <cfoutput>#PreserveSingleQuotes(where)#</cfoutput>
			<cfelse>
			</cfif>
			
     </cfif>
	ORDER BY #sort# #dir#
    OFFSET #start# ROWS
         FETCH NEXT #limit# ROWS ONLY
	
    <!---<cfif Ucase(client.DBMS) EQ 'MYSQL'>
     	LIMIT #start#, #limit#
    <cfelseif Ucase(client.DBMS) EQ 'MSSQL'>
         OFFSET #start# ROWS
         FETCH NEXT #limit# ROWS ONLY
    <cfelse>
    	LIMIT #start#, #limit#
    </cfif>--->
	  ;
	       
	
</cfquery>

  
<cfquery name="countTotal" datasource="IBOSE_GLOBAL">
	 SELECT  COUNT(*) AS TOTALREC
	   FROM GINEXITINTERVIEWFORM
      
     <cfif isdefined('url.query')>
	   WHERE nameofemployee LIKE '%#url.query#%'
	 <cfelse>
	    <cfif trim(where) NEQ "()">
			WHERE <cfoutput>#PreserveSingleQuotes(where)#</cfoutput>
		<cfelse>
		</cfif>
     </cfif>
	
	  ;
</cfquery>

<cfset cnt = 0 >

<cfoutput>
	
	#callback#(
	{
    "totalCount":"#countTotal.TOTALREC#",
	"topics":[
	
		<cfloop query="getExitForm">
			
		{
			"controlnumber":         #SerializeJSON(CONTROLNUMBER)#,
			"company":               #SerializeJSON(company)#,
			"dateofaccomplishment":  #SerializeJSON(dateofaccomplishment)#,
			"nameofemployee":        #SerializeJSON(nameofemployee)#,
			"employeenumber":                      #SerializeJSON(employeenumber)#, 
			"immediatesuperior":                      #SerializeJSON(immediatesuperior)#, 
			"department":                      #SerializeJSON(department)#, 
			"age":                      #SerializeJSON(age)#, 
			"currentposition":                      #SerializeJSON(currentposition)#, 
			"positionuponhire":                      #SerializeJSON(positionuponhire)#, 
			"datehired":                      #SerializeJSON(datehired)#,
			"effectdateresign":                      #SerializeJSON(effectdateresign)#,
			"lengthofservice":                      #SerializeJSON(lengthofservice)#,
			"localopportunity":                      #SerializeJSON(localopportunity1)#,
			"industrynxtemp":                      #SerializeJSON(industrynxtemp)#,
			"companynxtemp":                      #SerializeJSON(companynxtemp)#, 
			"expectedtomeet":                      #SerializeJSON(expectedtomeet)#, 
			"expectmeetremarks":                      #SerializeJSON(expectmeetremarks)#, 
			"changesaffected":                      #SerializeJSON(changesaffected)#, 
			"changesremarks":                      #SerializeJSON(changesremarks)#, 
			"developfull":                      #SerializeJSON(developfull)#, 
			"developfullremarks":                      #SerializeJSON(developfullremarks)#,
			"answerproblems":                      #SerializeJSON(answerproblems)#,
			"problemsremarks":                      #SerializeJSON(problemsremarks)#,
			"improvements":                      #SerializeJSON(improvements)#,
			"improvementsremarks":                      #SerializeJSON(improvementsremarks)#,
			"factorsfacilitated":                      #SerializeJSON(factorsfacilitated)#, 
			"factorshindered":                      #SerializeJSON(factorshindered)#, 
			"comppolicies":                      #SerializeJSON(comppolicies)#, 
			"comppolicyremarks":                      #SerializeJSON(comppolicyremarks)#, 
			"compreputation":                      #SerializeJSON(compreputation)#, 
			"compreputationremarks":                      #SerializeJSON(compreputationremarks)#, 
			"seniorlead":                      #SerializeJSON(seniorlead)#,
			"seniorleadremarks":                      #SerializeJSON(seniorleadremarks)#,
			"superiorimmed":                      #SerializeJSON(superiorimmed)#,
			"superiorimmedremarks":                      #SerializeJSON(superiorimmedremarks)#,
			"coworkers":                      #SerializeJSON(coworkers)#,
			"coworkersremarks":                      #SerializeJSON(coworkersremarks)#, 
			"customers":                      #SerializeJSON(customers)#, 
			"customersremarks":                      #SerializeJSON(customersremarks)#, 
			"salary":                      #SerializeJSON(salary)#, 
			"salaryremarks":                      #SerializeJSON(salaryremarks)#, 
			"benefits":                      #SerializeJSON(benefits)#, 
			"benefitsremarks":                      #SerializeJSON(benefitsremarks)#,
			"perfmgnt":                      #SerializeJSON(perfmgnt)#,
			"perfmgntremarks":                      #SerializeJSON(perfmgntremarks)#,
			"recognition":                      #SerializeJSON(recognition)#,
			"recognitionremarks":                      #SerializeJSON(recognitionremarks)#,
			"workk":                      #SerializeJSON(workk)#, 
			"workremarks":                      #SerializeJSON(workremarks)#, 
			"resourcespeople":                      #SerializeJSON(resourcespeople)#, 
			"resourcespeopleremarks":                      #SerializeJSON(resourcespeopleremarks)#, 
			"empcommu":                      #SerializeJSON(empcommu)#, 
			"empcommuremarks":                      #SerializeJSON(empcommuremarks)#, 
			"workprocess":                      #SerializeJSON(workprocess)#,
			"workprocessremarks":                      #SerializeJSON(workprocessremarks)#,
			"careeropp":                      #SerializeJSON(careeropp)#,
			"careeroppremarks":                      #SerializeJSON(careeroppremarks)#,
			"traindevopp":                      #SerializeJSON(traindevopp)#,
			"traindevoppremarks":                      #SerializeJSON(traindevoppremarks)#, 
			"worklifebal":                      #SerializeJSON(worklifebal)#, 
			"worklifebalremarks":                      #SerializeJSON(worklifebalremarks)#, 
			"workcondition":                      #SerializeJSON(workcondition)#, 
			"workconditionremarks":                      #SerializeJSON(workconditionremarks)#, 
			"overallwork":                      #SerializeJSON(overallwork)#, 
			"overallworkremarks":                      #SerializeJSON(overallworkremarks)#,
			"applyfutureyes":                      #SerializeJSON(applyfutureyes)#,
			"applyfutureremarks":                      #SerializeJSON(applyfutureremarks)#,
			"remarksfinalresignee":                      #SerializeJSON(remarksfinalresignee)#,
			"resigneeremarkdate":                      #SerializeJSON(resigneeremarkdate)#,
			"rmrksfinterviewer":                      #SerializeJSON(rmrksfinterviewer)#, 
			"interviewerrmrkdate":                      #SerializeJSON(interviewerrmrkdate)#, 
			"datelastupdate":                      #SerializeJSON(datelastupdate)#
			
		}
	
		<cfif countTotal.TOTALREC NEQ cnt>
			<cfoutput>,</cfoutput>
			<cfset cnt = cnt + 1 >
	    </cfif>
		</cfloop>
	
	]  
	})
	
</cfoutput>
	<cfcatch>
		<cfoutput>
	
		#callback#(
		{
	    "totalCount":"1",
		"topics":[{
				"CONTROLNUMBER":  #SerializeJSON(cfcatch.Detail)#,
			},{
				"company":  #SerializeJSON(cfcatch.Message & ' -  ' & where)#,
			}]
		})
		</cfoutput>
	</cfcatch>
</cftry>



<cfsetting showdebugoutput="no" >